package com.jian.exception;

import com.jian.common.BaseResponse;
import com.jian.common.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public BaseResponse businessException(BusinessException e) {
        log.error("businessException: code===>"+
                e.getErrorCode().getCode() + ":" + e.getErrorCode().getMessage(), e);
        return ResultUtils.Error(e.getErrorCode(),e.getDescription());
    }
}
